<?php
namespace app\common\model\tools;

use think\Model;
use think\Db;
use app\common\model\base\System;

/*************************************************  
* ClassName:     短信宝短信发送类
* Description:   手机短信模型
*************************************************/

class Smsbao extends Model
{
    /**
    * send 发短信
    * @karl guoyu
    * @DateTime 2017-01-03T16:31:54+0800
    * @return   array                    [error_code, error_msg]
    */
    static public function send($mobile, $content)
    {
        $res = ['error_code' => 0, 'error_msg' => ""];
        if(!empty($mobile)){
            $smsapi = "http://api.smsbao.com/";		//短信网关
            $username = "yj123";
            $password = md5("QHdOE7ys56DV");
            $sendurl = $smsapi."sms?u=".$username."&p=".$password."&m=".$mobile."&c=".urlencode($content);
            $result = file_get_contents($sendurl); //.做返回测试
            $res['data']=$result;
        } else {
            $res['error_code'] = '1';
            $res['error_msg'] = '手机号为空';
        }
        return $res;
    }
}

?>